package com.dews.web.controller.warn;

import com.dews.common.annotation.Log;
import com.dews.common.core.controller.BaseController;
import com.dews.common.core.domain.BaseResponse;
import com.dews.common.core.page.TableDataInfo;
import com.dews.common.enums.BusinessType;
import com.dews.warn.domain.dto.NotificationMessageQueryDTO;
import com.dews.warn.domain.vo.NotificationMessageVo;
import com.dews.warn.service.INotificationMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 消息通知Controller
 * 
 * @author qingfeng
 * @date 2025-02-05
 */
@Api(value = "消息通知", tags = {"消息通知" })
@RestController
@RequestMapping("/warn/message")
public class NotificationMessageController extends BaseController {

    private INotificationMessageService notificationMessageService;

    @Autowired
    public NotificationMessageController(INotificationMessageService notificationMessageService) {
        this.notificationMessageService = notificationMessageService;
    }

    @ApiOperation(value = "获取消息通知列表")
    @PreAuthorize("@ss.hasPermi('warn:message:list')")
    @GetMapping("/list")
    public TableDataInfo list(NotificationMessageQueryDTO notificationMessageQueryDTO) {
        startPage();
        List<NotificationMessageVo> list = notificationMessageService.selectNotificationMessageList(notificationMessageQueryDTO);
        return getDataTable(list);
    }

    @ApiOperation(value = "获取消息通知详细信息")
    @PreAuthorize("@ss.hasPermi('warn:message:query')")
    @GetMapping(value = "/{id}")
    public BaseResponse getInfo(@PathVariable("id") Integer id) {
        return success(notificationMessageService.selectNotificationMessageById(id));
    }

    @ApiOperation(value = "删除消息通知")
    @PreAuthorize("@ss.hasPermi('warn:message:remove')")
    @Log(title = "消息通知", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public BaseResponse remove(@PathVariable List<Integer> ids) {
        return toAjax(notificationMessageService.deleteNotificationMessageByIds(ids));
    }


}
